const key = getFilePathStore(import.meta.url);

export const useHomeSettingCardComponentStore = defineStore(key, {
    state: () => ({
        usr: '',
        phone: '',
        adress: '',
        worker: '',
        iconUrl: '',
        rightArrow: false,
    }),
    actions: {
        changeUsr(newUsr: string) {
            this.usr = newUsr;
        },
        changePhone(newPhone: string) {
            this.phone = newPhone;
        },
        changeAdress(newAdress: string) {
            this.adress = newAdress;
        },
        changeWorker(newWorker: string) {
            this.worker = newWorker;
        },
        changeIconUrl(newIconUrl: string) {
            this.iconUrl = newIconUrl;
        },
        changRightArrow(haveRightArrow: boolean) {
            this.rightArrow = haveRightArrow ? true : false;
        },
        async initStore() {
            // TODO api:得到用户个人信息
            await getUserCardForUserInfo();
            // console.log("🚀 ~ initStore ~ userInfo:", userInfo)
            this.changeUsr('张三家的猫');
            this.changePhone('15613115535');
            this.changeAdress('河北省石家庄市桥西区');
            this.changeWorker('极客学院');
            this.changeIconUrl('https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg');
            this.changRightArrow(false);
        }
    },
    persist: {
        key: key,
        storage: sessionStorage
    }
})